//
//  YYEIntrolThirdCell.m
//  YuYingEDU
//
//  Created by 胡波 on 2018/1/3.
//  Copyright © 2018年 胡波. All rights reserved.
//

#import "YYEIntrolThirdCell.h"

@interface YYEIntrolThirdCell ()

@property (nonatomic,strong) UIImageView *backIV;
@property (nonatomic,strong) UIImageView *headerIV;
@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *levelLabel;
@property (nonatomic,strong) UILabel *experLabel;

@end

@implementation YYEIntrolThirdCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.contentView.backgroundColor = GeneralBackColor;
        
        self.backIV = [[UIImageView alloc]init];
        self.backIV.image = [UIImage imageNamed:@"bottomBorder"];
        // UIEdgeInsetsMake(0, 0, 30, 0) 里面的值是保护区域
        self.backIV.image = [self.backIV.image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 30, 0) resizingMode:(UIImageResizingModeStretch)];
        [self.contentView addSubview:self.backIV];
        
        self.headerIV = [[UIImageView alloc]init];
        [self.backIV addSubview:self.headerIV];
        
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.textColor = [UIColor blackColor];
        self.nameLabel.font = [UIFont systemFontOfSize:14];
        [self.backIV addSubview:self.nameLabel];
        
        self.levelLabel = [[UILabel alloc]init];
        self.levelLabel.textColor = [UIColor blackColor];
        self.levelLabel.font = [UIFont systemFontOfSize:11];
        [self.backIV addSubview:self.levelLabel];
        
        self.experLabel = [[UILabel alloc]init];
        self.experLabel.textColor = [UIColor blackColor];
        self.experLabel.font = [UIFont systemFontOfSize:13];
        self.experLabel.numberOfLines = 0;
        [self.backIV addSubview:self.experLabel];
        
//        self.headerIV.image = [UIImage imageNamed:@"teacherHolder"];
//        self.nameLabel.text = @"陈晨";
//        self.levelLabel.text = @"高级Java讲师";
//        self.experLabel.text = @"    多年Java培训经验，讲授过C、C++和C#语言程序设计，了解学生在学习程序设计过程中的困惑和常犯的错误。";
        
    }
    return self;
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.backIV makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(UIEdgeInsetsMake(0.5, 8, 10, 8));
    }];
    
    [self.headerIV makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.backIV.left).offset(16);
        make.top.equalTo(self.backIV.top).offset(8);
        make.size.equalTo(CGSizeMake(67, 67));
    }];
    
    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerIV.right).offset(10);
        make.bottom.equalTo(self.headerIV.centerY).offset(-3);
    }];
    
    [self.levelLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerIV.right).offset(10);
        make.top.equalTo(self.headerIV.centerY).offset(3);
    }];
    
    [self.experLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerIV.bottom).offset(6);
        make.left.equalTo(self.backIV.left).offset(10);
        make.right.equalTo(self.backIV.right).offset(-10);
//        make.bottom.equalTo(self.backIV.bottom).offset(-16);
    }];
    
}

- (void)setModel:(YYECourseIntroModel *)model {
    _model = model;
    
    [self.headerIV sd_setImageWithURL:[NSURL URLWithString:model.timg] placeholderImage:[UIImage imageNamed:@"teacherHolder"]];
    self.nameLabel.text = model.tname;
    self.levelLabel.text = model.role;
    self.experLabel.text = model.tintro;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
